<!doctype html>
<html>

	<head>
		<meta charset="utf-8">
		<title>编辑货物信息</title>
		<link rel="stylesheet" href="../../../layui/css/layui.css"  />
	</head>
	<body>
		
		<div class="layui-container" style="margin-top:20px;">
			<div class="layui-row">
				<div class="layui-col-md8 layui-col-md-offset2">
					<form class="layui-form layui-form-pane" >
						<input type="hidden" name="id" id="id"/>
						<div class="layui-form-item">
						  <label class="layui-form-label">货物名称</label>
						  <div class="layui-input-inline">
						    <input type="text" id="name" name="name" autocomplete="off" placeholder="请输入" lay-verify="required" class="layui-input">
						  </div>
						  <div class="layui-form-mid layui-text-em">请务必填写货物名称</div>
						</div>
						<div class="layui-form-item">
						  <label class="layui-form-label">货物重量</label>
						  <div class="layui-input-inline">
						    <input type="text" id="weight" name="weight" autocomplete="off" placeholder="请输入" lay-verify="required" class="layui-input">
						  </div>
						</div>
					  <div class="layui-form-item">
					    <label class="layui-form-label">始发地</label>
					    <div class="layui-input-block">
					      <input type="text" id="startStation" name="startStation" autocomplete="off" placeholder="请输入" lay-verify="required" class="layui-input">
					    </div>
					  </div>
					  <div class="layui-form-item">
					    <label class="layui-form-label">目的地</label>
					    <div class="layui-input-block">
					      <input type="text" id="endStation" name="endStation" autocomplete="off" placeholder="请输入" lay-verify="required" class="layui-input">
					    </div>
					  </div>
					  <div class="layui-form-item">
					    <label class="layui-form-label">运费单价</label>
					    <div class="layui-input-inline">
					      <input type="text" id="freight" name="freight" autocomplete="off" placeholder="请输入" lay-verify="required" class="layui-input">
					    </div>
					  </div>
					  
					  <div class="layui-form-item">
					    <button class="layui-btn" lay-submit lay-filter="edit">更新货物</button>
					    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
					  </div>
					</form>
				</div>
			</div>
		</div>
		<script src="../../../layui/layui.js"></script>
		<script>
			layui.use(function(){
				let laydate=layui.laydate;
				let $ = layui.$;
				let layer=layui.layer;
				let form=layui.form;
				let upload=layui.upload;
				
				form.on("submit(edit)",function(data){
					let field=data.field;
					//AJAX向后端发送请求
					$.ajax({
						type:"put",
						url:"http://47.120.50.119:8086/goods/updateGoods",
						data:JSON.stringify(field),
						contentType:'application/json',
						dataType:"json",
						success:function(d){
							console.log(d)
							if(d.code==0){
								let index=parent.layer.getFrameIndex(window.name);
								parent.layer.close(index);
							}else{
								layer.msg(d.msg);
							}
						}
					});
					return false;
				});
				
				
			})
		</script>
	</body>

</html>